package eteam.aps.service.impl;

import eteam.aps.common.entity.ParentEntity;
import eteam.aps.mapper.QueryInfoMapper;
import eteam.aps.model.entity.DataDictionaryCategory;
import eteam.aps.model.entity.ProtectionOrg;
import eteam.aps.service.QueryInfoService;
import eteam.aps.systeminterface.model.vo.QueryInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 查询信息业务层
 *
 * @author WMT
 * @Date 2023/2/3 14:17
 */
@Service
public class QueryInfoServiceImpl implements QueryInfoService {

    @Autowired
    private QueryInfoMapper queryInfoMapper;

    @Override
    public Map<String,String> selectUserName() {
        Map<String, String> userMap = new HashMap<>();
        userList().forEach(
                queryInfoVo -> {
                    userMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return userMap;
    }

    @Override
    public Map<String,String> selectOrgName() {
        Map<String, String> orgMap = new HashMap<>();
        orgList().forEach(
                queryInfoVo -> {
                    orgMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return orgMap;
    }


    @Override
    public Map<String, String> selectOrgCode() {
        Map<String, String> orgCodeMap = new HashMap<>();
        orgCodeList().forEach(
                queryInfoVo -> {
                    orgCodeMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return orgCodeMap;
    }


    @Override
    public Map<String,String> selectProOrgName() {
        Map<String, String> proOrgMap = new HashMap<>();
        proOrgList().forEach(
                queryInfoVo -> {
                    proOrgMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return proOrgMap;
    }

    @Override
    public Map<String, String> selectDdName() {
        Map<String,String> dicMap = new HashMap<>();
        dictionaryList().forEach(
                queryInfoVo -> {
                    dicMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return dicMap;
    }

    @Override
    public Map<String, String> selectDepotName() {
        Map<String,String> depotMap = new HashMap<>();
        depotList().forEach(
                queryInfoVo -> {
                    depotMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return depotMap;
    }

    @Override
    public Map<String, String> selectProducerName() {
        Map<String,String> producerMap = new HashMap<>();
        producerList().forEach(
                queryInfoVo -> {
                    producerMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return producerMap;
    }

    @Override
    public Map<String, String> selectModelName() {
        Map<String,String> modelMap = new HashMap<>();
        modelList().forEach(
                queryInfoVo -> {
                    modelMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return modelMap;
    }

    @Override
    public Map<String, String> selectUnitName() {
        Map<String,String> unitMap = new HashMap<>();
        unitList().forEach(
                queryInfoVo -> {
                    unitMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return unitMap;
    }

    @Override
    public Map<String, String> selectFundName() {
        Map<String,String> fundMap = new HashMap<>();
        fundInfoList().forEach(
                queryInfoVo -> {
                    fundMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return fundMap;
    }

    @Override
    public List<QueryInfoVo> selectDdInfo(String ddcName) {
        return queryInfoMapper.dictList(ddcName);
    }

    @Override
    public Map<String, String> selectPreserveLevelName() {
        Map<String,String> preserveLevelMap = new HashMap<>();
        preserveLevelList().forEach(
                queryInfoVo -> {
                    preserveLevelMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return preserveLevelMap;
    }

    @Override
    public Map<String, String> selectRepairsLevelName() {
        Map<String,String> patrolsRepairsLevelMap = new HashMap<>();
        patrolsRepairsList().forEach(
                queryInfoVo -> {
                    patrolsRepairsLevelMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return patrolsRepairsLevelMap;
    }

    @Override
    public Map<String, String> selectRepairName() {
        Map<String,String> repairMap = new HashMap<>();
        repairList().forEach(
                queryInfoVo -> {
                    repairMap.put(queryInfoVo.getId(),queryInfoVo.getName());
                }
        );
        return repairMap;
    }

    @Override
    public List<QueryInfoVo> dictionaryList() {
        return queryInfoMapper.dictionaryList(ParentEntity.FSTATE_DELETED);
    }


    @Override
    public List<QueryInfoVo> maintainPlanList() {
        return queryInfoMapper.maintainPlanList(ParentEntity.FSTATE_DELETED);
    }



    @Override
    public List<QueryInfoVo> orgCodeList() {
        return queryInfoMapper.orgCodeList(QueryInfoVo.STATE_ENABLE);
    }

    @Override
    public List<QueryInfoVo> personList(String fOrgId) {
        Map<String,Object> map = new HashMap<>(2);
        map.put("state",QueryInfoVo.STATE_ENABLE);
        map.put("fPersonType",QueryInfoVo.PERSON_TYPE_USER);
        map.put("fOrgId",fOrgId);
        return queryInfoMapper.personList(map);
    }

    @Override
    public List<QueryInfoVo> userList() {
        Map<String,Object> map = new HashMap<>(2);
        map.put("state",QueryInfoVo.STATE_ENABLE);
        map.put("fPersonType",QueryInfoVo.PERSON_TYPE_USER);
        return queryInfoMapper.personList(map);
    }

    @Override
    public List<QueryInfoVo> fundInfoList() {
        return queryInfoMapper.fundInfoList(ParentEntity.FSTATE_DELETED);
    }


    @Override
    public List<QueryInfoVo> orgList() {
        return queryInfoMapper.orgList(QueryInfoVo.STATE_ENABLE);
    }

    @Override
    public List<QueryInfoVo> proOrgList() {
        return queryInfoMapper.proOrgList(ParentEntity.FSTATE_DELETED);
    }

    @Override
    public List<QueryInfoVo> depotList() {
        return queryInfoMapper.depotList(ParentEntity.FSTATE_DELETED);
    }

    @Override
    public List<QueryInfoVo> producerList() {
        Map<String,Object> map = new HashMap<>(2);
        map.put("fState",ParentEntity.FSTATE_DELETED);
        map.put("fOrgCategory", ProtectionOrg.FORGCATEGORY_PRODUCER);
        return queryInfoMapper.producerList(map);
    }

    @Override
    public List<QueryInfoVo> modelList() {
        return queryInfoMapper.dictList(DataDictionaryCategory.FDDCNAME_MODEL);
    }

    @Override
    public List<QueryInfoVo> unitList() {
        return queryInfoMapper.dictList(DataDictionaryCategory.FDDCNAME_UNIT);
    }

    @Override
    public List<QueryInfoVo> preserveLevelList() {
        return queryInfoMapper.dictList(DataDictionaryCategory.FDDCNAME_PRESERVE_LEVEL);
    }

    @Override
    public List<QueryInfoVo> patrolsRepairsList() {
        return queryInfoMapper.dictList(DataDictionaryCategory.FDDCNAME_PATROLS_REPAIRS_LEVEL);
    }

    @Override
    public List<QueryInfoVo> repairList() {
        return queryInfoMapper.dictList(DataDictionaryCategory.FDDCNAME_REPAIR_LEVEL);
    }
}
